# Maintainer: Jean-Michaël Celerier <jeanmichael.celerier at gmail dot com>

_realname=cninja
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=3.7.6
pkgrel=1
pkgdesc="cninja, an opinionated cmake config manager"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/jcelerier/cninja"
license=('AGPLv3')
depends=("${MINGW_PACKAGE_PREFIX}-cmake"
         "${MINGW_PACKAGE_PREFIX}-clang"
         "${MINGW_PACKAGE_PREFIX}-lld"
         "${MINGW_PACKAGE_PREFIX}-ninja"
         "${MINGW_PACKAGE_PREFIX}-libc++")
makedepends=("${MINGW_PACKAGE_PREFIX}-boost")
source=("https://github.com/jcelerier/cninja/releases/download/v${pkgver}/cninja-v${pkgver}-src.tar.gz")
sha512sums=('ad21e6d1648cca2a2b0ac5fba322109c0f43410e14125af47ccf129cdb26e2e9cc576900f13383b50fff1afbd85560575cb47506eca2c4c93059d8016874ecec')

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST} 
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}
 
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -GNinja \
    -Wno-dev \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
     "$srcdir"

  cmake --build .
}

package() {
  cd "$srcdir/build-${MINGW_CHOST}"
  DESTDIR="${pkgdir}" cmake --build . --target install/strip

  install -D -m644 "$srcdir/LICENSE.md" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
